﻿#if ANDROID
using KinonekoSoftware.Foundation.Platform;
using AndroidOS = global::Android.OS.Environment;

#endif

#if AVALONIA
namespace KinonekoSoftware.Platform
{
    partial class NativeApplication
    {
#if PAD && ANDROID
        
        public string GetSpecialFolder(SpecialFolder folder)
        {
            var uri = folder switch
            {
                SpecialFolder.Documents => AndroidOS.GetExternalStoragePublicDirectory(AndroidOS.DirectoryDocuments),
                SpecialFolder.Downloads => AndroidOS.GetExternalStoragePublicDirectory(AndroidOS.DirectoryDownloads),
                SpecialFolder.Music     => AndroidOS.GetExternalStoragePublicDirectory(AndroidOS.DirectoryMusic),
                SpecialFolder.Video     => AndroidOS.GetExternalStoragePublicDirectory(AndroidOS.DirectoryMovies),
                SpecialFolder.Picture   => AndroidOS.GetExternalStoragePublicDirectory(AndroidOS.DirectoryPictures),

                _ => AndroidOS.GetExternalStoragePublicDirectory(AndroidOS.DirectoryDocuments),
            };

            return uri?.Path;
        }

        public string CheckDirectoryOrCreate(string dir)
        {
            if (string.IsNullOrEmpty(dir))
            {
                throw new ArgumentNullException(nameof(dir));
            }

            var file = new global::Java.IO.File(dir);
            
            if (!file.Exists())
            {
                global::Android.Systems.Os.Mkdir(dir, 0777);
            }

            return dir;
        }

        protected abstract TabbedWindow CreateMainView();
        
        
        
        public void  InstallExceptionHandler()
        {
            
        }
#endif
    }
}


#endif